package com.iteaj.iot;

import com.iteaj.iot.codec.filter.CombinedFilter;
import org.springframework.beans.factory.ObjectProvider;
import org.springframework.boot.context.properties.EnableConfigurationProperties;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.PropertySource;

import java.util.List;

/**
 * create time: 2022/1/16
 *
 * @author iteaj
 * @since 1.0
 */
@PropertySource("classpath:IOTCore.properties")
@EnableConfigurationProperties(IotCoreProperties.class)
public class IotCoreConfiguration {

    private final IotCoreProperties coreProperties;

    public IotCoreConfiguration(IotCoreProperties coreProperties) {
        this.coreProperties = coreProperties;
    }

    @Bean
    public IotThreadManager iotThreadManager() {
        return IotThreadManager.instance();
    }

    @Bean
    public FilterManager filterManager(ObjectProvider<List<CombinedFilter>> filters) {
        return new FilterManager(filters.getIfAvailable());
    }
}
